return 1;
}
+static void vmx_init_hypercall_page(struct domain *d, void *hypercall_page)
+{
+ char *p;
+ int i;
+
+ memset(hypercall_page, 0, PAGE_SIZE);
+
+ for ( i = 0; i < (PAGE_SIZE / 32); i++ )
+ {
+ p = (char *)(hypercall_page + (i * 32));
+ *(u8 *)(p + 0) = 0xb8; /* mov imm32, %eax */
+ *(u32 *)(p + 1) = i;
+ *(u8 *)(p + 5) = 0x0f; /* vmcall */
+ *(u8 *)(p + 6) = 0x01;
+ *(u8 *)(p + 7) = 0xc1;
+ *(u8 *)(p + 8) = 0xc3; /* ret */
+ }
+
+ /* Don't support HYPERVISOR_iret at the moment */
+ *(u16 *)(hypercall_page + (__HYPERVISOR_iret * 32)) = 0x0b0f; /* ud2 */
+}
+
/* Setup HVM interfaces */
static void vmx_setup_hvm_funcs(void)
{
hvm_funcs.get_guest_ctrl_reg = vmx_get_ctrl_reg;
hvm_funcs.init_ap_context = vmx_init_ap_context;
-}
-static void vmx_init_hypercall_page(struct domain *d, void *hypercall_page)
-{
- char *p;
- int i;
-
- memset(hypercall_page, 0, PAGE_SIZE);
-
- for ( i = 0; i < (PAGE_SIZE / 32); i++ )
- {
- p = (char *)(hypercall_page + (i * 32));
- *(u8 *)(p + 0) = 0xb8; /* mov imm32, %eax */
- *(u32 *)(p + 1) = i;
- *(u8 *)(p + 5) = 0x0f; /* vmcall */
- *(u8 *)(p + 6) = 0x01;
- *(u8 *)(p + 7) = 0xc1;
- *(u8 *)(p + 8) = 0xc3; /* ret */
- }
-
- /* Don't support HYPERVISOR_iret at the moment */
- *(u16 *)(hypercall_page + (__HYPERVISOR_iret * 32)) = 0x0b0f; /* ud2 */
+ hvm_funcs.init_hypercall_page = vmx_init_hypercall_page;
}
int start_vmx(void)
vmx_setup_hvm_funcs();
- hvm_funcs.init_hypercall_page = vmx_init_hypercall_page;
-
hvm_enabled = 1;
return 1;